# import sqlite3   #导入sqlite3模块
# db = r"D:\sqlite\test3.db"
# conn = sqlite3.connect(db)
# print("成功打开数据库")
# c = conn.cursor()  # 获取游标
# sql = '''
#    select count(*) from tb_model
# '''
#
# cursor = c.execute(sql)  # 执行sql语句
# print(cursor)
# # for row in cursor:
# #     print("id = ",row[0])
# #     print("name = ",row[1])
# #     print("address = ",row[2])
# #     print("salary = ",row[3],"\n")
#
# conn.close()  # 关闭数据库链接
# print("成功查找数据")

import socket
import argparse
import threading
from sqltb import *
from myutils import *
from mydefine import *
from fsocket import *
from mydata import *

# 加载网络模型
feature_net = loadModel("pointsia-b", "pointsia-b_best_neg")
# 连接数据库
database = DBMysql(name = r"D:\sqlite\test3.db")
tb_model = TBModel(database=database, feature_net=feature_net)

# with open("E:\\coding\\320\\MXZYGL\\client\\bin\\off\\airplane_0627.txt", "r") as file:
#     data = file.read()
#     # data = [[int(value) for value in row] for row in data]
#     print(data)

filename = 'E:\\coding\\320\\MXZYGL\\client\\bin\\off\\airplane_0627.txt'
data = []

with open(filename, 'r') as file:
    for line in file:
        row = [float(x) for x in line.split(',')]
        data.append(row)
merged_data = [item for sublist in data for item in sublist]

print(merged_data)
points = torch.tensor(list(merged_data)).view(1, -1, 3)
status, models = tb_model.search_by_feature(points)

